package org.wangblue.concrete_visitor;

import org.wangblue.concrete_elements.Book;
import org.wangblue.concrete_elements.Elect;
import org.wangblue.visitor.Visitor;

/**
 * @description: 具体访问者
 * @author: WangBlue (wangjiping596@gmail.com)
 * @create: 2024-10-02 11:25
 **/
public class PriceVisitor extends Visitor {
    private double totalPrice = 0.0;
    @Override
    public void visit(Book book) {
        totalPrice += book.getPrice();

    }

    @Override
    public void visit(Elect electronic) {
        totalPrice += electronic.getPrice();
    }

    public double getTotalPrice() {
        return totalPrice;
    }
}
